home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / glibc.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2008-09-29  |  7KB  |  192 lines

  1. #! /bin/sh -e
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides:          glibc
  5. # Required-Start:
  6. # Required-Stop:
  7. # Default-Start:     S
  8. # Default-Stop:
  9. ### END INIT INFO
  10. #
  11. # This script detects deprecated kernel versions incompatible with
  12. # the current version of the glibc
  13.  
  14. # glibc kernel version check: KERNEL_VERSION_CHECK
  15. linux_compare_versions () {
  16.     verA=$(($(echo "$1" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  17.     verB=$(($(echo "$3" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  18.  
  19.     test $verA -$2 $verB
  20. }
  21.  
  22. kfreebsd_compare_versions () {
  23.     verA=$(($(echo "$1" | sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \* 100 + \2/')))
  24.     verB=$(($(echo "$3" | sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \* 100 + \2/')))
  25.  
  26.     test $verA -$2 $verB
  27. }
  28.  
  29. kernel26_help() {
  30.     echo ""
  31.     echo "The installation of a 2.6 kernel _could_ ask you to install a new libc"
  32.     echo "first, this is NOT a bug, and should *NOT* be reported. In that case,"
  33.     echo "please add etch sources to your /etc/apt/sources.list and run:"
  34.     echo "  apt-get install -t etch linux-image-2.6"
  35.     echo "Then reboot into this new kernel, and proceed with your upgrade"
  36. }
  37.  
  38. exit_check () {
  39.     sleep 5
  40.     exit 1
  41. }
  42.  
  43.     system=`uname -s`
  44.     if [ "$system" = "Linux" ]
  45.     then
  46.         # Test to make sure z < 255, in x.y.z-n form of kernel version
  47.         # Also make sure we don't trip on x.y.zFOO-n form
  48.         #kernel_rev=$(uname -r | tr -- - . | cut -d. -f3 | tr -d '[:alpha:]')
  49.         kernel_rev=$(uname -r | sed 's/\([0-9]*\.[0-9]*\.\)\([0-9]*\)\(.*\)/\2/')
  50.         if [ "$kernel_rev" -ge 255 ]
  51.         then
  52.             echo "WARNING: Your kernel version indicates a revision number"
  53.             echo "of 255 or greater.  Glibc has a number of built in"
  54.             echo "assumptions that this revision number is less than 255."
  55.             echo "If you\'ve built your own kernel, please make sure that any"
  56.             echo "custom version numbers are appended to the upstream"
  57.             echo "kernel number with a dash or some other delimiter."
  58.  
  59.             exit_check
  60.         fi
  61.  
  62.         # sanity checking for the appropriate kernel on each architecture.
  63.         realarch=`uname -m`
  64.         kernel_ver=`uname -r`
  65.  
  66.         # convert "armv4l" and similar to just "arm", and "mips64" and similar
  67.         # to just "mips"
  68.         case $realarch in
  69.           arm*) realarch="arm";;
  70.           mips*) realarch="mips";;
  71.         esac
  72.  
  73.  
  74.         # From glibc 2.3.5-7 real-i386 is dropped.
  75.         if [ "$realarch" = i386 ]
  76.         then
  77.             echo "WARNING: This machine has real i386 class processor."
  78.             echo "Debian etch and later does not support such old hardware"
  79.             echo "any longer."
  80.             echo "The reason is that \"bswap\" instruction is not supported"
  81.             echo "on i386 class processors, and some core libraries have"
  82.             echo "such instruction.  You\'ll see illegal instruction error"
  83.             echo "when you upgrade your Debian system."
  84.             exit_check
  85.         fi
  86.  
  87.         # arm boxes require __ARM_NR_set_tls in the kernel to function properly.
  88.         if [ "$realarch" = arm ]
  89.         then
  90.             if linux_compare_versions "$kernel_ver" lt 2.6.12
  91.             then
  92.                 echo WARNING: This version of glibc requires that you be running
  93.                 echo kernel version 2.6.12 or later.  Earlier kernels contained
  94.                 echo bugs that may render the system unusable if a modern version
  95.                 echo of glibc is installed.
  96.                 kernel26_help
  97.                 exit_check
  98.             fi    
  99.         fi
  100.  
  101.         # Alpha and HPPA boxes require latest fixes in the kernel to function properly.
  102.         if [ "$realarch" = parisc -o "$realarch" = alpha ]
  103.         then
  104.             if linux_compare_versions "$kernel_ver" lt 2.6.9
  105.             then
  106.                 echo WARNING: This version of glibc requires that you be running
  107.                 echo kernel version 2.6.9 or later.  Earlier kernels contained
  108.                 echo bugs that may render the system unusable if a modern version
  109.                 echo of glibc is installed.
  110.                 kernel26_help
  111.                 exit_check
  112.             fi
  113.         fi
  114.  
  115.         # sh4 boxes require kernel version 2.6.11 minimum
  116.         if [ "$realarch" = sh4 ]
  117.         then
  118.             if linux_compare_versions "$kernel_ver" lt 2.6.11
  119.             then
  120.                 echo WARNING: This version of glibc requires that you be running
  121.                 echo kernel version 2.6.11 or later.  Earlier kernels contained
  122.                 echo bugs that may render the system unusable if a modern version
  123.                 echo of glibc is installed.
  124.                 kernel26_help
  125.                 exit_check
  126.             fi    
  127.         fi
  128.  
  129.         # The GNU libc requires 2.6 kernel (except on m68k) because we drop to
  130.         # support linuxthreads
  131.         if [ "$realarch" != m68k ]
  132.         then
  133.             if linux_compare_versions "$kernel_ver" lt 2.6.8
  134.             then
  135.                 echo WARNING: POSIX threads library NPTL requires kernel version
  136.                 echo 2.6.8 or later.  If you use a kernel 2.4, please upgrade it
  137.                 echo before installing glibc.
  138.                 kernel26_help
  139.                 exit_check
  140.             fi
  141.         fi
  142.  
  143.         # The GNU libc is now built with --with-kernel= >= 2.4.1 on m68k
  144.         if [ "$realarch" = m68k ]
  145.         then
  146.             if linux_compare_versions "$kernel_ver" lt 2.4.1
  147.             then
  148.                 echo WARNING: This version of glibc requires that you be running
  149.                 echo kernel version 2.4.1 or later.  Earlier kernels contained
  150.                 echo bugs that may render the system unusable if a modern version
  151.                 echo of glibc is installed.
  152.                 kernel26_help
  153.                 exit_check
  154.             fi
  155.         fi
  156.  
  157.         # From glibc 2.6-3 SPARC V8 support is dropped.
  158.         if [ "$realarch" = sparc ]
  159.         then
  160.             # The process could be run using linux32, check for /proc.
  161.             if [ -f /proc/cpuinfo ]
  162.             then
  163.                case "$(sed '/^type/!d;s/^type.*: //g' /proc/cpuinfo)" in
  164.                    sun4u)
  165.                       # UltraSPARC CPU
  166.                       ;;
  167.                    sun4v)
  168.                       # Niagara CPU
  169.                       ;;
  170.                    *)
  171.                       echo "WARNING: This machine has a SPARC V8 or earlier class processor."
  172.                       echo "Debian lenny and later does not support such old hardware"
  173.                       echo "any longer."
  174.                       exit_check
  175.                       ;;
  176.                esac
  177.             fi
  178.         fi
  179.     elif [ $system = "GNU/kFreeBSD" ] ; then
  180.         kernel_ver=`uname -r`
  181.         if kfreebsd_compare_versions "$kernel_ver" lt 6.0
  182.         then
  183.             echo WARNING: This version of glibc uses UMTX_OP_WAIT and UMTX_OP_WAKE
  184.         echo syscalls that are not present in the current running kernel. They
  185.         echo have been added in kFreeBSD 6.0.  Your system should still work,
  186.         echo but it is recommended to upgrade to a more recent version.
  187.         fi
  188.     fi
  189.  
  190. : exit 0
  191.